<?php

use Elastic\Elasticsearch\Client;
use Elastic\Elasticsearch\ClientBuilder;

require_once __DIR__ . '/../vendor/autoload.php';

const EsHost = "host.docker.internal:9200",
EsIndex      = "test";

const Tab       = "\n\t",
EventCreate     = "create-index",
EventUpsertData = "upsert-data",
EventGetData    = "get-data";

function esClient(): Client
{
    $client = ClientBuilder::create()
        ->setHosts([EsHost])
        ->build();

    return $client;
}

function errorMessage(): string
{
    return "请选择 event 事件列表:" . Tab .
        "-e=" . EventCreate . ": 创建索引" . Tab .
        "-e=" . EventUpsertData . ": 批量更新数据" . Tab .
        "-e=" . EventGetData . ": 获取数据" . Tab .
        PHP_EOL;
}